package com.gae.tutorial;

import java.io.IOException;
import java.util.Date;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class GaeSingletonServlet extends HttpServlet {
	
	private int counter = 0; 
	private static int staticcounter = 0; 
	
	public GaeSingletonServlet(){
		super();	
	}
	
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		String s = req.getParameter("s");
		
		resp.setContentType("text/plain");
		
		if(s != null){
			try {
				int i = Integer.parseInt(s);
				Thread.sleep(i);
			} catch (InterruptedException e) {
				
			}
		}
		
		resp.getWriter().println("Static: " + GaeSingletonServlet.staticcounter++);
		resp.getWriter().println("Local: " + counter++);
		resp.getWriter().println("Date: " + (new Date()).toString());
		return;
		
	}
}
